package jhourglass;

import java.util.TimerTask;

import javax.swing.JOptionPane;

public class JHourTimerTask extends TimerTask{

	private JHourGlass jHourGlass;
	
	public JHourTimerTask(JHourGlass jHourGlass){
		this.jHourGlass = jHourGlass;
	}

	@Override
	public void run() {
		
		int pressed = JOptionPane.showConfirmDialog(null, jHourGlass.getTimeInMinute()
				+ " minutes passed. If you want to restart, press OK",
				"Restart Timer", JOptionPane.OK_CANCEL_OPTION,
				JOptionPane.INFORMATION_MESSAGE);
		
		if (pressed != JOptionPane.YES_OPTION) {
			jHourGlass.endTimer();
			return;
		}
		jHourGlass.startTimer();
		
	}
}
